#ifndef I2C_MMA_H
#define I2C_MMA_H

#include "cpu.h"

/**MMA8452��д��ַ*/
#if (USW_ACC_IC_TYPE == 1)	
#define MMA8452Q_WRITE      0x38
#define MMA8452Q_READ       0x39

#elif (USW_ACC_IC_TYPE == 2 || USW_ACC_IC_TYPE == 3 || USW_ACC_IC_TYPE == 4)
#define MMA8452Q_WRITE      0x30
#define MMA8452Q_READ       0x31
#endif

/**ͨѶ����ģʽ����*/
#define MMA_SDA_OUT()       GPIOA->CRH &= 0xfff0ffff;GPIOA->CRH |= 0x00010000;//0101
#define MMA_SDA_IN()        GPIOA->CRH &= 0xfff0ffff;GPIOA->CRH |= 0x00080000;GPIOA->ODR |= 1<<12;//0100

/**ͨѶ���߲���*/
#define MMA_SDA_HIGH()      GPIOA->ODR |= (1<<12);
#define MMA_SDA_LOW()       GPIOA->ODR &= ~(1<<12);
#define MMA_SCK_LOW()       GPIOA->ODR &= ~(1<<11);
#define MMA_SCK_HIGH()      GPIOA->ODR |= (1<<11);
#define MMA_SDA_READ()      ((GPIOA->IDR)&(1<<12))

I2CStatus MMA8452Q_WriteReg(INT8U Reg, INT8U Data);
void MMA8452Q_ReadData(INT8U Reg, INT8U *Buff, INT8U Len);

#endif



